<template>
  <div class="title-tpl">
    <div v-if="visible">
      <span class="title-leave">{{formatTitle.a}}</span>
      <span>{{formatTitle.b}}</span>
    </div>
    <div v-else class="hint-title">{{value}}</div>
  </div>
</template>
<script>
export default {
  name: 'title-tpl',
  props: {
    value: String,
    visible: {
      type: Boolean,
      default: true
    }
  },
  computed: {
    formatTitle() {
      return {
        a: this.value.slice(0, 1),
        b: this.value
      }
    }
  }
}
</script>
<style lang="less" scoped>
.title-tpl {
  font-size: 0.36rem;
  color: #222222;
  font-weight: 500;
  .title-leave {
    display: inline-block;
    width: 0.52rem;
    height: 0.52rem;
    line-height: 0.52rem;
    background: linear-gradient(
      225deg,
      rgba(255, 161, 92, 1) 0%,
      rgba(255, 125, 61, 1) 100%
    );
    border-radius: 50%;
    text-align: center;
    color: #ffffff;
    margin-right: 0.16rem;
  }
  .hint-title {
    position: relative;
    font-size: 0.3rem;
    padding-left: 6px;
    &::before {
      content: "";
      width: 4px;
      height: 80%;
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      background: linear-gradient(
        225deg,
        rgba(255, 161, 92, 1) 0%,
        rgba(255, 125, 61, 1) 100%
      );
      border-radius: 2px;
    }
  }
}
</style>
